const App = getApp()

const light = [
  {
    "pagePath": "/pages/index/index",
    "text": "首页",
    "iconPath": "/image/navbar/1-2.png",
    "selectedIconPath": "/image/navbar/1-3.png"
  },
  {
    "pagePath":"/pages/exclusive/exclusive",
    "text": "专属",
    "iconPath": "/image/navbar/2-2.png",
    "selectedIconPath": "/image/navbar/2-3.png"
  },
  {
    "pagePath": "/pages/store-map/store-map",
    "text": "预约",
    "iconPath": "/image/navbar/3-2.png",
    "selectedIconPath": "/image/navbar/3-3.png"
  },
  {
    "pagePath": "/pages/user/user",
    "text": "我的",
    "iconPath": "/image/navbar/4-2.png",
    "selectedIconPath": "/image/navbar/4-3.png"
  }
]

const dark = [
  {
    "pagePath": "/pages/index/index",
    "text": "首页",
    "iconPath": "/image/navbar/1-2.png",
    "selectedIconPath": "/image/navbar/1-1.png"
  },
  {
    "pagePath":"/pages/exclusive/exclusive",
    "text": "专属",
    "iconPath": "/image/navbar/2-2.png",
    "selectedIconPath": "/image/navbar/2-1.png"
  },
  {
    "pagePath": "/pages/store-map/store-map",
    "text": "预约",
    "iconPath": "/image/navbar/3-2.png",
    "selectedIconPath": "/image/navbar/3-1.png"
  },
  {
    "pagePath": "/pages/user/user",
    "text": "我的",
    "iconPath": "/image/navbar/4-2.png",
    "selectedIconPath": "/image/navbar/4-1.png"
  }
]
Component({
  data: {
    night: App.globalData.darkMode,
    selected: 0,
    selectedColor: "#000",
    list: light
  },
  attached () {
    const mode = this.data.night
    const list = mode ? dark : light
    const selectedColor = mode ? '#fff' : '#000'
    this.setData({list, selectedColor})

  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const { path:url, index:selected } = data
      wx.switchTab({url})
      this.setData({selected})
    }
  }
})